//package com.sport.utils;
//
//import com.aliyun.oss.*;
//import com.aliyun.oss.model.PutObjectRequest;
//import com.aliyun.oss.model.PutObjectResult;
//import lombok.Data;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//
///**
// * 用于Ali产品的配置 （OSS）
// * @author: Orcas
// * @version:1.0.0
// * @date: 2019/4/28
// */
//// @PropertySource("classpath:xxxx.properties") 默认路径下可不加
//@Data
//@Component
//public class aliyunUtils {
//    // 地域节点
//    @Value("${aliyun.oss.endpoint}")
//    private String endpoint;
////    @Value("${aliyun.accessKey}")
//    private String accessKeyId="LTAI5tDMo5aYhS6yAU6Zqk6H";
////    @Value("${aliyun.secret}")
//    private String accessKeySecret="4fMqcWiqboaCOrHCxajt8ju2tC63kl";
//
//    @Value("${aliyun.oss.bucketName}")
//    private String bucketName;
//    @Value("${aliyun.oss.urlPrefix}")
//    private String urlPrefix;
//
//
//    // 创建OSSClient实例。
//    OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
//
//    public PutObjectResult client(String fileName,String filePath) {
//        try {
//            // 创建PutObjectRequest对象。
//            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileName, new File(filePath));
//            // 如果需要上传时设置存储类型和访问权限，请参考以下示例代码。
//            // ObjectMetadata metadata = new ObjectMetadata();
//            // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
//            // metadata.setObjectAcl(CannedAccessControlList.Private);
//            // putObjectRequest.setMetadata(metadata);
//
//            // 上传文件。
//            PutObjectResult putObjectResult = ossClient.putObject(putObjectRequest);
//            return putObjectResult;
//        } catch (OSSException oe) {
//            System.out.println("Caught an OSSException, which means your request made it to OSS, "
//                    + "but was rejected with an error response for some reason.");
//            System.out.println("Error Message:" + oe.getErrorMessage());
//            System.out.println("Error Code:" + oe.getErrorCode());
//            System.out.println("Request ID:" + oe.getRequestId());
//            System.out.println("Host ID:" + oe.getHostId());
//        } catch (ClientException ce) {
//            System.out.println("Caught an ClientException, which means the client encountered "
//                    + "a serious internal problem while trying to communicate with OSS, "
//                    + "such as not being able to access the network.");
//            System.out.println("Error Message:" + ce.getMessage());
//        } finally {
//            if (ossClient != null) {
//
//                ossClient.shutdown();
//            }
//        }
//        return null;
//    }
//
//}
